//
//  relodTableVC.swift
//  Test
//
//  Created by 代亚洲 on 2017/3/9.
//  Copyright © 2017年 DengJinHui. All rights reserved.
//

import UIKit

class relodTableVC: UITableViewController {
    
    override func viewDidLoad() {
        setUPView()
    }
    
    func setUPView() {
        self.title = "reload"
        self.tableView.register(tabelCell.self, forCellReuseIdentifier: tabelCell.reuseID)
    }
    
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 2
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return 2
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        var cell:tabelCell! = tableView.dequeueReusableCell(withIdentifier: tabelCell.reuseID, for: indexPath) as? tabelCell
        if cell == nil {
            cell = tabelCell(style: .default, reuseIdentifier: tabelCell.reuseID)
        }
        return cell
    }
    
}

class tabelCell: UITableViewCell {
    
    static let reuseID = "tabelCell"
    // 酒店图
    private let hotelImageView1: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "u=3398587189,57981062&fm=23&gp=0")
        return imageView
    }()
    // 酒店图
    private let hotelImageView2: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "u=3398587189,57981062&fm=23&gp=0")
        return imageView
    }()
    // 酒店图
    private let hotelImageView3: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "u=3398587189,57981062&fm=23&gp=0")
        return imageView
    }()
    // 酒店图
    private let hotelImageView7: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "u=3398587189,57981062&fm=23&gp=0")
        return imageView
    }()
    // 酒店图
    private let hotelImageView4: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "u=3398587189,57981062&fm=23&gp=0")
        return imageView
    }()
    // 酒店图
    private let hotelImageView5: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "u=3398587189,57981062&fm=23&gp=0")
        return imageView
    }()
    // 酒店图
    private let hotelImageView6: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "u=3398587189,57981062&fm=23&gp=0")
        return imageView
    }()
    // 酒店图
    private let hotelImageView8: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "u=3398587189,57981062&fm=23&gp=0")
        return imageView
    }()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        setupView()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupView(){
        hotelImageView1.autoPinEdge(toSuperviewEdge: .top,withInset: 5)
        hotelImageView1.autoPinEdge(toSuperviewEdge: .left,withInset: 5)
        hotelImageView1.autoSetDimensions(to: CGSize.init(width: 20, height: 20))
        
        hotelImageView2.autoPinEdge(toSuperviewEdge: .top,withInset: 5)
        hotelImageView2.autoPinEdge(.left, to: .right, of: hotelImageView1)
        hotelImageView2.autoSetDimensions(to: CGSize.init(width: 20, height: 20))
        
        hotelImageView3.autoPinEdge(toSuperviewEdge: .top,withInset: 5)
        hotelImageView3.autoPinEdge(.left, to: .right, of: hotelImageView2)
        hotelImageView3.autoSetDimensions(to: CGSize.init(width: 20, height: 20))
        
        hotelImageView4.autoPinEdge(toSuperviewEdge: .top,withInset: 5)
        hotelImageView4.autoPinEdge(.left, to: .right, of: hotelImageView3)
        hotelImageView4.autoSetDimensions(to: CGSize.init(width: 20, height: 20))
        
        hotelImageView5.autoPinEdge(.top, to: .bottom, of: hotelImageView4 ,withOffset: 5)
        hotelImageView5.autoPinEdge(.left, to: .right, of: hotelImageView1)
        hotelImageView5.autoSetDimensions(to: CGSize.init(width: 20, height: 20))
        
        hotelImageView6.autoPinEdge(.top, to: .bottom, of: hotelImageView4 ,withOffset: 5)
        hotelImageView6.autoPinEdge(.left, to: .right, of: hotelImageView5)
        hotelImageView6.autoSetDimensions(to: CGSize.init(width: 20, height: 20))
        
        hotelImageView7.autoPinEdge(.top, to: .bottom, of: hotelImageView4 ,withOffset: 5)
        hotelImageView7.autoPinEdge(.left, to: .right, of: hotelImageView6)
        hotelImageView7.autoSetDimensions(to: CGSize.init(width: 20, height: 20))
        
        hotelImageView8.autoPinEdge(.top, to: .bottom, of: hotelImageView4 ,withOffset: 5)
        hotelImageView8.autoPinEdge(.left, to: .right, of: hotelImageView7)
        hotelImageView8.autoSetDimensions(to: CGSize.init(width: 20, height: 20))
    }
    
    func setData(name: String){
        hotelImageView1.image = UIImage.init(named: name)
        hotelImageView2.image = UIImage.init(named: name)
        hotelImageView3.image = UIImage.init(named: name)
        hotelImageView4.image = UIImage.init(named: name)
        hotelImageView5.image = UIImage.init(named: name)
        hotelImageView6.image = UIImage.init(named: name)
        hotelImageView7.image = UIImage.init(named: name)
        hotelImageView8.image = UIImage.init(named: name)
    }
}
